<template>
    <template v-for="item in props.menuList">
        <el-sub-menu v-if="item.IS_MENU == '1' && item.PARENT_ID == props.parentId" :index="item.ID"
            >
            <template #title>
                <div >
                    <el-icon>
                        <component :is="item.ICON" />
                    </el-icon>
                    <span>{{ item.NAME }}</span>
                </div>
            </template>

            <menuList :menuList="props.menuList" :parentId="item.ID" />
        </el-sub-menu>

        <el-menu-item @click="selectMenuItem(item)" v-if="item.IS_MENU == '2' && item.PARENT_ID == props.parentId"
            :index="item.ID" >
            <template #title>
                <div >
                    <el-icon>
                        <component :is="item.ICON" />
                    </el-icon>
                    <span>{{ item.NAME }}</span>
                </div>

            </template>
        </el-menu-item>

    </template>
</template>

<script setup>
import { getCurrentInstance } from 'vue'
const emit = defineEmits(['click'])

import menuList from './MenuList.vue'

const props = defineProps(['menuList', 'parentId'])


const cxt = getCurrentInstance() //相当于Vue2中的this
const bus = cxt.appContext.config.globalProperties.$bus


function selectMenuItem(aobjItem) {
    //console.log(this.$root)
    bus.emit('system_menu_click', aobjItem)
    //emit('clickItem' , aobjItem)
    //console.log(aobjItem)
}

</script>

<style></style>